import { post, get, del } from "@/api/index";
import { APIResponse, ApiParams, LoadDataTableRes } from "@/api/types";

const bookUrl = 'book'

export function getBooks(pageNo: number, pageSize: number, params: ApiParams) {
  return get<APIResponse<LoadDataTableRes>>(`${bookUrl}/` + pageNo + '/' + pageSize, params)
}

export function getBook(id: string, params: ApiParams) {
  return get<APIResponse<LoadDataTableRes>>(`${bookUrl}/` + id, params)
}

export function saveBook(params: ApiParams) {
  return post<APIResponse<LoadDataTableRes>>(`${bookUrl}`, params, { showLoading: true, showTips: true })
}

export function deleteBook(id: string, params: ApiParams) {
  return del<APIResponse<LoadDataTableRes>>(`${bookUrl}/` + id, params, { showLoading: true, showTips: false })
}

export function updateBook(params: ApiParams) {
  return post<APIResponse<LoadDataTableRes>>(`${bookUrl}`, params, { showLoading: true, showTips: true })
}

